import {defineStore} from "pinia";

export const useDialogLevelStore = defineStore('dialogLevel', {
  state: () => ({
    dialogShows: <any>[]
  }),
  getters: {
  },
  actions: {
    add(key) {
      const oldDom = document.body.getElementsByClassName(this.dialogShows[0])?.[0]
      if (oldDom) {
        oldDom.style.display = 'none'
      }
      this.dialogShows.unshift(key)
    },
    del(key) {
      this.dialogShows = this.dialogShows.filter(v => v !== key)
      const newDom = document.body.getElementsByClassName(this.dialogShows[0])?.[0]
      if (newDom) {
        newDom.style.display = 'unset'
      }
    },
  },
})
